#!coding:utf-8
# vim: tabstop=4 shiftwidth=4 softtabstop=4

"""
    @author jay.han
"""

import logging

from cvirt.cnode.libvirtXmlObject.baseDomain import GuestDevice
LOG = logging.getLogger(__name__)


class GuestInput(GuestDevice):
    ROOT_NAME = "input"
    def __init__(self, parse_xml=None, **kw):
        super(GuestInput, self).__init__(parse_xml=parse_xml,**kw)
        self.type = "tablet"
        self.bus = "usb"

    def _parse_xml(self, xmldoc):
        self.type = xmldoc.get('type')
        self.bus = xmldoc.get('bus')

    def _get_xml_config(self, root):
        if self.type:
            root.set("type", self.type)
        if self.bus:
            root.set("bus", self.bus)
        return root

class GuestInputMouse(GuestInput):
    def __init__(self, parse_xml=None, **kw):
        super(GuestInput, self).__init__(parse_xml=parse_xml,**kw)
        self.type = "mouse"
        self.bus = "ps2"


class GuestSound(GuestDevice):
    ROOT_NAME = "sound"
    def __init__(self, parse_xml=None, **kw):
        super(GuestSound, self).__init__(parse_xml=parse_xml,**kw)
        self.model='ac97' # ac97 ich6

    def _parse_xml(self, xmldoc):

        self.model = xmldoc.get('model')

    def _get_xml_config(self, root):
        dev = root
        dev.set('model',self.model)
        return dev



